<?xml version="1.0" encoding="ISO-8859-1" ?>

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:rich="http://richfaces.org/rich"
	  xmlns:a4j="http://richfaces.org/a4j"
	  xmlns:easy="http://easyfaces.com.br/easyfaces">
	
	<f:subview id="subviewManterServico">
	
		<script type="text/javascript">		
			function preencheDadosPopupCategoria(codigoCategoria, descricaoCategoria) {
				document.getElementById('subviewManterServico:formServicoManter:servico_categoria_codigo').value = codigoCategoria;
				document.getElementById('subviewManterServico:formServicoManter:servico_categoria_descricao').value = descricaoCategoria;
			}	
			
		</script>
		
		<rich:modalPanel id="manterServico" autosized="true" headerClass="height:20px;" resizeable="false">
			<f:facet name="header">
				<h:outputText value="Manter Servico" />
			</f:facet>
			<f:facet name="controls">
				<h:panelGroup>
					<h:graphicImage value="/images/close.gif" styleClass="botao_fechar_popup" id="hideLink">
						<rich:componentControl for="manterServico" attachTo="hideLink" operation="hide" event="onclick" />
					</h:graphicImage>
				</h:panelGroup>
			</f:facet>
			<b><font color="red"><rich:messages id="msgServicoManter"></rich:messages></font></b>
				<a4j:form ajaxSubmit="true" id="formServicoManter" > 


               <h:inputHidden id="servico_categoria_codigo" value="#{servicoBackBean.servicoFormBean.servicoManter.categoriaVO.codigo}" />
               	
              <rich:panel>  
               <h:panelGrid columns="3" width = "600px;">   
               
              <h:outputLabel style="color:red;" value="Tipo de Servico* "/>
						<h:selectOneRadio id="servico_tipo" value="#{servicoBackBean.servicoFormBean.servicoManter.tipo}" disabled="#{servicoBackBean.servicoFormBean.isExcluirDisabled || (!servicoBackBean.servicoFormBean.isExcluirDisabled &amp;&amp; !servicoBackBean.servicoFormBean.isGravarDisabled)}">
							<f:selectItem itemValue="1" itemLabel="Passeio" />
							<f:selectItem itemValue="2" itemLabel="Transporte" />
							<f:selectItem itemValue="3" itemLabel="Hotel" />
						</h:selectOneRadio>  
                
              </h:panelGrid>  
             </rich:panel>   

              <rich:jQuery selector="servico_categoria_descricao" timing="onload" query="attr('readOnly', true)" />

              <rich:panel>

   				<h:panelGrid columns="3">
   				
	                	<h:outputLabel style="color:red;" value="Descricao * " for="servico_categoria_descricao" />
	                	<h:inputText id="servico_categoria_descricao" value="#{servicoBackBean.servicoFormBean.servicoManter.categoriaVO.descricao}" label="#{bundle.servico_categoria_descricao}" disabled="#{servicoBackBean.servicoFormBean.isExcluirDisabled || (!servicoBackBean.servicoFormBean.isExcluirDisabled &amp;&amp; !servicoBackBean.servicoFormBean.isGravarDisabled)}" size="40" maxlength="50" readonly="true" />
	                    <a4j:commandButton value="#{bundle.servico_btn_popup}" id="btnPopupCategoria" disabled="#{servicoBackBean.servicoFormBean.isExcluirDisabled}"  readonly="#{!servicoBackBean.servicoFormBean.isExcluirDisabled &amp;&amp; !servicoBackBean.servicoFormBean.isGravarDisabled}" >
	                    	<rich:componentControl for="popupCategoria" attachTo="btnPopupCategoria" operation="show" event="onclick" />
	                    </a4j:commandButton>

             	</h:panelGrid>
             	
	   				<h:panelGrid columns="3">
   				
	                	<h:outputLabel style="color:red;" value="Fornecedor* " for="servico_fornecedor" />
	                	<h:inputText id="servico_fornecedor" value="#{servicoBackBean.servicoFormBean.servicoManter.fornecedorVO.nome}" label="#{bundle.servico_categoria_descricao}" disabled="#{servicoBackBean.servicoFormBean.isExcluirDisabled || (!servicoBackBean.servicoFormBean.isExcluirDisabled &amp;&amp; !servicoBackBean.servicoFormBean.isGravarDisabled)}" size="40" maxlength="50" readonly="true" />
	                    <a4j:commandButton value="#{bundle.servico_btn_popup}" id="btnPopupFornecedor" disabled="#{servicoBackBean.servicoFormBean.isExcluirDisabled}"  readonly="#{!servicoBackBean.servicoFormBean.isExcluirDisabled &amp;&amp; !servicoBackBean.servicoFormBean.isGravarDisabled}" >
	                    	<rich:componentControl for="popupCategoria" attachTo="btnPopupFornecedor" operation="show" event="onclick" />
	                    </a4j:commandButton>

             	</h:panelGrid>
             	
             	   
             </rich:panel>
              			
			
			<rich:panel>	
				
                <h:panelGrid columns="4">
                
                    
                    <h:outputLabel value="Credito Disponivel" for="servico_estoqueA" />
                    <h:inputText id="servico_estoqueA" value="#{servicoBackBean.servicoFormBean.servicoManter.estoqueAtual}" label="#{bundle.servico_estoqueA}"  maxlength="10" size="15" disabled="#{servicoBackBean.servicoFormBean.isExcluirDisabled}"  readonly="#{!servicoBackBean.servicoFormBean.isExcluirDisabled &amp;&amp; !servicoBackBean.servicoFormBean.isGravarDisabled}"  />
                    
               </h:panelGrid>
                 
                   <div class="linha"/>
                    
               <h:panelGrid columns="4">
                    
                    <h:outputLabel value="Preco de Compra" for="servico_precoC" />
		            <easy:inputCurrency id="servico_precoC" value="#{servicoBackBean.servicoFormBean.servicoManter.precoCompra}" decimalSeparator="," groupSeparator="." returnDecimal="true"  submitWithMask="true" maxlength="10"  size="10" disabled="true"  />
	                
	                <h:outputLabel value="Preco de Venda" for="servico_precoV" />
		            <easy:inputCurrency id="servico_precoV" value="#{servicoBackBean.servicoFormBean.servicoManter.precoVenda}" decimalSeparator="," groupSeparator="." returnDecimal="true"  submitWithMask="true" maxlength="10" size="10" disabled="#{servicoBackBean.servicoFormBean.isExcluirDisabled}"  readonly="#{!servicoBackBean.servicoFormBean.isExcluirDisabled &amp;&amp; !servicoBackBean.servicoFormBean.isGravarDisabled}"   />
	               
	                <h:outputLabel value="Data da Ultima Compra" for="servico_data_ultimaCompra" />
	                <rich:calendar id="servico_data_ultimaCompra" value="#{servicoBackBean.servicoFormBean.servicoManter.dataUltimaCompra}" inputStyle="width:5em" label="#{bundle.servico_dataUltimaCompra}"  size="15" datePattern="dd/MM/yyyy" disabled="true" />
	                
	               	<h:outputLabel value="Data da Ultima Venda" for="servico_data_ultimaVenda" />
	                <rich:calendar id="servico_data_ultimaVenda" value="#{servicoBackBean.servicoFormBean.servicoManter.dataUltimaVenda}" inputStyle="width:5em" label="#{bundle.servico_dataUltimaVenda}"  size="15" datePattern="dd/MM/yyyy" disabled="true" />
              	               
                </h:panelGrid>
                    
               </rich:panel> 
                
                <h:panelGrid columns="2">
					<h:outputLabel value="#{bundle.servico_observacoes}:" for="servico_observacoes" />
	                <h:inputTextarea id="servico_observacoes" value="#{servicoBackBean.servicoFormBean.servicoManter.observacoes}" label="#{bundle.servico_observacoes}" disabled="#{servicoBackBean.servicoFormBean.isExcluirDisabled}"  readonly="#{!servicoBackBean.servicoFormBean.isExcluirDisabled &amp;&amp; !servicoBackBean.servicoFormBean.isGravarDisabled}" maxlength="50" cols="40" rows="3" />
				</h:panelGrid>
			<div class="linha"/>
			<div class="linha"/>
                
               <h:outputLabel value="#{bundle.campos_obrigatorios} (*) " style="color:red;"/>  
               <div class="linha"/>		
             
               <a4j:commandButton  value="#{bundle.servico_btn_gravar}"  action="#{servicoBackBean.manterServico}"   oncomplete="if (#{facesContext.maximumSeverity==null}) #{rich:component('manterServico')}.hide(); " reRender="formServicoConsulta, formServicoPopup, gridServico" disabled="#{!servicoBackBean.servicoFormBean.isGravarDisabled}" />
                <a4j:commandButton action="#{servicoBackBean.excluirServico}" value="#{bundle.servico_btn_excluir}" id="btnExcluir" reRender="gridServico" disabled="#{!servicoBackBean.servicoFormBean.isExcluirDisabled}" >
                	<rich:componentControl for="manterServico" attachTo="btnExcluir" operation="hide" event="onclick" />
                </a4j:commandButton>
                
                <a4j:commandButton value="#{bundle.servico_btn_voltar}" id="btnVoltar" action="#{servicoBackBean.obterListaServico}"  reRender="gridServico" >
                	<rich:componentControl for="manterServico" attachTo="btnVoltar" operation="hide" event="onclick" />
                </a4j:commandButton>
				
			</a4j:form>

		</rich:modalPanel>
	</f:subview>

	<ui:include src="/pages/categoria/popupCategoria.xhtml" />
	<ui:include src="/pages/fornecedor/popupFornecedor.xhtml" />

</html>